import unittest
import anneal
import numpy as np
import Mad

class TestAFT(unittest.TestCase):
    def setUp(self):
        self.times = np.linspace(100,0,100)
        self.temps = np.linspace(140,20,100)
        # Laslett FA model, estimates by HeFTy
        self.las_age = 66.9     
        self.las_len = 13.41
        self.age, self.r = anneal.Ketcham2007FC.get_age_r(self.times, self.temps,True)

        self.mad_l = np.zeros(17)
        self.mad_age = Mad.trax(self.times,self.temps,1,1,self.mad_l)
        print self.mad_l
        
    def test_LaslettAgeHeFTy(self):
        self.assertAlmostEqual(self.las_age,  self.age, places=0)
        

    def test_LaslettLenHeFTy(self):
        self.assertAlmostEqual(self.las_len,  np.mean(16.3*self.r[self.r>0.13]), places=1)
        
 
    def test_LaslettAgeMad(self):
        self.assertAlmostEqual(self.mad_age, self.age, places=0)
 
        
if __name__ == '__main__':
    unittest.main()
